#coding:utf-8

'''登陆验证,可以整合注册与登陆,但是这里没有整合'''

from ihome.api_1_0 import api
from flask import request, jsonify, current_app,session
from ihome.utils.response_code import RET
from ihome import redis_store
from ihome.models import User
from ihome import db

import re


#判断用户是否登陆
@api.route('/session/login')
def check_login():
    user_name = session.get('user_name')
    if user_name:
        return jsonify(errno=RET.OK,errmsg='已经登陆',data={'user_name':user_name})
    else:
        return jsonify(errno=RET.SERVERERR, errmsg='用户未登陆')


@api.route('/session/logout',methods=['DELETE'])
def logout():
    session.clear()
    return jsonify(errno=RET.OK,errmsg='退出成功')
